package com.yiyue.graduate.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yiyue.graduate.dao.CourseMapper;
import com.yiyue.graduate.pojo.Course;
import com.yiyue.graduate.service.CourseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author yiyuexiaofusheng
 */
@Service
public class CourseServiceImpl implements CourseService {

    @Resource
    CourseMapper courseMapper;

    public List<Course> queryFreeCourse(){
        Map<String,Object> columnMap = new HashMap<>();
        columnMap.put("course_sort","免费课程");
        return courseMapper.selectByMap(columnMap);
    }
    public List<Course> queryTopCourse(){
        Map<String,Object> columnMap = new HashMap<>();
        columnMap.put("course_sort","精品课程");
        return courseMapper.selectByMap(columnMap);
    }
    public List<Course> queryMajorCourse(){
        Map<String,Object> columnMap = new HashMap<>();
        columnMap.put("course_sort","专业课程");
        return courseMapper.selectByMap(columnMap);
    }

    @Override
    public Course queryOneCourse(Long id) {
        QueryWrapper<Course> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",id);
        return courseMapper.selectOne(queryWrapper);
    }

    @Override
    public List<Course> queryAllCourse() {
        return courseMapper.queryAllCourse();

    }

    @Override
    public Course getUser(Long id) {
        return courseMapper.getUser(id);

    }

}
